#include "../iBe.h"

Processor::Processor()
{}

Processor::~Processor()
{}

ProcessorPtr Processor::createProcessor(int _id)
{
  ProcessorPtr retProcessor;

  switch(_id)
    {
    case STUB_PROC:
      retProcessor.reset( new StubProcessor() );
      break;

    case TEST_PROC:
      retProcessor.reset( new TestProcessor() );
      break;
    }

  return retProcessor;
}

StubProcessor::StubProcessor()
{}

StubProcessor::~StubProcessor()
{}

void StubProcessor::init(ScenePtr _scene)
{}

int StubProcessor::update(UINT64 &_time)
{
  return 0;
}

TestProcessor::TestProcessor()
{}

TestProcessor::~TestProcessor()
{}

void TestProcessor::init(ScenePtr _scene )
{
  ResourceManagerPtr resourceManager = ResourceManager::instance();
  Turple3f eye, center, up;
  CircularTrackPtr track1;
  LocationControllerPtr controller1;
  ObjectPtr object;
  //String ball1("ball_1");
  String halfcube1("halfcube_1");
  String plan1("plan_1");
  String plan2("plan_2");

  track1.reset(new CircularTrack());
  track1->setStartEndTime(0, 30000);
  track1->setLoop(false);
  track1->setRadius(1.5);

  eye[0] = eye[1] = 0;
  eye[2] = 6;

  center[0] = center[1] = 0;
  center[2] = -10;

  up[0] = up[2] = 0;
  up[1] = 1;

  _scene->setCamera(eye, center, up);

  object = resourceManager->getObject(halfcube1);

  if (object)
    {
      controller1 = object->getLocationController();
      controller1->setTrack(track1);
      object->setController(controller1);
    }

  _scene->addObject(object);


  object = resourceManager->getObject(plan1);

  if (object)
    {
      std::cout << "Plan created" << std::endl;
      _scene->addObject(object);
    }
  else
    {
      std::cout << "No plan created" << std::endl;
    }

  object = resourceManager->getObject(plan2);
  _scene->addObject(object);
}

int TestProcessor::update(UINT64 &_time)
{
  return 0;
}
